<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateMenusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('menus', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('pid')->unsigned()->default(0)->comment('对应的主菜单id , 主菜单的pid为0 , 判断菜单等级level判断是否是主菜单');
            $table->string('title', 60)->default('')->comment('菜单名称');
            $table->string('url', 60)->default('')->nullable()->comment('菜单地址');
            $table->string('icon', 80)->default('')->comment('菜单图标');
            $table->tinyInteger('level')->default(0)->comment('菜单等级:0主菜单, 1子菜单');
            $table->tinyInteger('sort')->default(0)->comment('排序比重');
            $table->integer('next')->default(0)->comment('主菜单存id，子菜单存主菜单id，用于查询');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `menus` comment '菜单表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('menus');
    }
}
